#!/bin/sh

# Absolute paths
AMIXER="/usr/bin/amixer"
AWK="/usr/bin/awk"
TR="/usr/bin/tr"

# Get current volume percentage
volume=$($AMIXER -D pulse sget Master | $AWK -F '[][]' '/%/ {print $2; exit}' | $TR -d '%')

# Check if volume is numeric
if ! echo "$volume" | grep -E '^[0-9]+$' > /dev/null; then
    echo "󰝟  "  # Mute glyph if volume is not numeric
    exit 1
fi

# Determine the mute status
mute_status=$($AMIXER -D pulse sget Master | grep 'Playback' | grep '\[off\]')

# Determine the glyph based on volume percentage and mute status
if [ -n "$mute_status" ]; then
    echo "󰝟"  # Mute glyph
elif [ "$volume" -eq 0 ]; then
    echo "󰝟"  # Mute glyph if volume is 0%
else
    echo "󰕾"  # Full volume glyph with volume percentage
fi

